define(["jquery","bbcare"],function($,$bb){
	var servers = {};
	var URL = $bb.baseUrl("followapp");

	/**
	 * 查询医生排班
	 */
	servers.ajaxScheduleList = function(callback){
		$bb.ajax({
			url: URL + "ctrl/docmanage/randOutPatientScheduleList",
			success: function(data){
				if(data.success){
					callback(data);
				}else{
					$bb.toastShow(data.msg ? data.msg : "查询医生排班出错！");
				}	
			}
		});
	}

	//工作日处理
    servers.work = function(workDay){
        switch(workDay){
            case "1":
                return "monday";
            case "2":
                return "tuesday";
            case "3":
                return "wednesday";
            case "4":
                return "thursday";
            case "5":
                return "friday";
            case "6":
                return "saturday";
            default:
                return "sunday";
        }
    }

    /**
	 * 新增排班
	 */
	servers.ajaxScheduleListAdd = function(params,callback,dom,flag){
		$bb.ajax({
			url: URL + "ctrl/docmanage/randOutPatientScheduleAdd",
			data:JSON.stringify({
				data : params
			}),
			success: function(data){
				if(data.success){
					callback(data.data,dom,flag);
				}else{
					$bb.toastShow(data.msg ? data.msg : "新增排班出错！");
				}	
			}
		});
	}

	/**
	 * 取消排班
	 */
	servers.ajaxScheduleDel = function(params,callback,dom,flag){
		$bb.ajax({
			url: URL + "ctrl/docmanage/randOutPatientScheduleDel",
			data:JSON.stringify({
				data : params
			}),
			success: function(data){
				if(data.success){
					callback(data.data,dom,flag);
				}else{
					$bb.toastShow(data.msg ? data.msg : "取消排班出错！");
				}	
			}
		});
	}

	return servers;
});